{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6455b906",
   "metadata": {},
   "source": [
    "## 导入所需的包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9185f791",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-07-22T06:45:23.042899Z",
     "start_time": "2021-07-22T06:45:21.362981Z"
    }
   },
   "outputs": [],
   "source": [
    "from autox import AutoX\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import os"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e124822c",
   "metadata": {},
   "source": [
    "## 配置数据路径"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fbc0d25b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-07-22T06:45:23.047787Z",
     "start_time": "2021-07-22T06:45:23.044916Z"
    }
   },
   "outputs": [],
   "source": [
    "path = './data/zhidemai'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa24e429",
   "metadata": {},
   "source": [
    "## 配置数据信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c6da0e63",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-07-22T06:47:18.816045Z",
     "start_time": "2021-07-22T06:47:18.803847Z"
    }
   },
   "outputs": [],
   "source": [
    "# 数据表对应的数据列特征类型\n",
    "feature_type = {\n",
    "    'train.csv': {\n",
    "        'article_id': 'cat',\n",
    "         'date': 'num',\n",
    "         'baike_id_1h': 'cat',\n",
    "         'price': 'num',\n",
    "         'price_diff': 'num',\n",
    "         'author': 'cat',\n",
    "         'level1': 'cat',\n",
    "         'level2': 'cat',\n",
    "         'level3': 'cat',\n",
    "         'level4': 'cat',\n",
    "         'brand': 'cat',\n",
    "         'mall': 'cat',\n",
    "         'url': 'cat',\n",
    "         'comments_1h': 'num',\n",
    "         'zhi_1h': 'num',\n",
    "         'buzhi_1h': 'num',\n",
    "         'favorite_1h': 'num',\n",
    "         'orders_1h': 'num',\n",
    "         'baike_id_2h': 'cat',\n",
    "         'comments_2h': 'num',\n",
    "         'zhi_2h': 'num',\n",
    "         'buzhi_2h': 'num',\n",
    "         'favorite_2h': 'num',\n",
    "         'orders_2h': 'num',\n",
    "         'orders_3h_15h': 'num'\n",
    "    },\n",
    "    'test.csv': {\n",
    "        'article_id': 'cat',\n",
    "         'date': 'num',\n",
    "         'baike_id_1h': 'cat',\n",
    "         'price': 'num',\n",
    "         'price_diff': 'num',\n",
    "         'author': 'cat',\n",
    "         'level1': 'cat',\n",
    "         'level2': 'cat',\n",
    "         'level3': 'cat',\n",
    "         'level4': 'cat',\n",
    "         'brand': 'cat',\n",
    "         'mall': 'cat',\n",
    "         'url': 'cat',\n",
    "         'comments_1h': 'num',\n",
    "         'zhi_1h': 'num',\n",
    "         'buzhi_1h': 'num',\n",
    "         'favorite_1h': 'num',\n",
    "         'orders_1h': 'num',\n",
    "         'baike_id_2h': 'cat',\n",
    "         'comments_2h': 'num',\n",
    "         'zhi_2h': 'num',\n",
    "         'buzhi_2h': 'num',\n",
    "         'favorite_2h': 'num',\n",
    "         'orders_2h': 'num'\n",
    "    }\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b722824a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-07-22T06:43:21.650069Z",
     "start_time": "2021-07-22T06:43:18.318898Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# target表示标%save列\n",
    "# train_name表示训练集主表表名\n",
    "# test_name表示测试集主表表名\n",
    "# id表示样本的唯一Id\n",
    "\n",
    "# 初始化autox:\n",
    "autox = AutoX(target = 'orders_3h_15h', train_name = 'train.csv', test_name = 'test.csv', \n",
    "               id = ['article_id'], path = path, feature_type = feature_type)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc6898fc",
   "metadata": {
    "ExecuteTime": {
     "start_time": "2021-07-22T06:49:25.234Z"
    },
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 调用autox的get_submit函数，获得test的预测结果\n",
    "sub = autox.get_submit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ebcf66d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "sub.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04b395ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "sub.to_csv(\"./autox_sub.csv\", index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b6fa0939",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e020572d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
